package com.test.lock;

import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

public class ProducerAndConsumerMain {
    public static void main(String[] args) {
        ConcurrentLinkedQueue<Integer> container = new ConcurrentLinkedQueue();
        ReentrantLock lock = new ReentrantLock();
        Condition producerCondition = lock.newCondition();
        Condition consumerCondition = lock.newCondition();
        Thread threadProducer = new Thread(new Producer(container, lock, producerCondition, consumerCondition));
        Thread threadConsumer = new Thread(new Consumer(container, lock, producerCondition, consumerCondition));
        Thread threadConsumer2 = new Thread(new Consumer(container, lock, producerCondition, consumerCondition));

        threadConsumer.start();
        threadConsumer2.start();
        threadProducer.start();
    }
}
